"""
This file demonstrates writing tests using the unittest module. These will pass
when you run "manage.py test".

Replace this with more appropriate tests for your application.
"""

from django.test import TestCase




class SimpleTest(TestCase):
    def test_basic_addition(self):
        """
        Tests that 1 + 1 always equals 2.
        """
        self.assertEqual(1 + 1, 2)

		
from django.test import TestCase
from django.utils import unittest
from django.core import management;
from models import *
from django.test.client import Client

""" Author: Pauline Kazman"""
class loginTestCase(TestCase):
	def test_logIn(self):
		self.User.objects.assertEqual(email="pauline.kazman@gmail.com", password="123456")
		self.assertEqual(self.user.email, "pauline.kazman@gmail.com", self.user.password,"123456")
class resetPasswordTestCase(TestCase):
	def setUp(self):
		self.user = User.objects.create( password = "123456", newpassword="abc123",confirmpassword = "abc123")
	def	test_resetPassword(self):
	
		
""" Author: Sherine Nouh """
class TemplatesViewsTestCase(TestCase):
    def test_index(self):
        resp = self.client.get('/viewTemplates/')
        self.assertEqual(resp.status_code, 200)
        
  
        
""" Author: Sherine Nouh """      
class TestSession(TestCase):
 
    def setUp(self):
  

    
        
        media = Media.objects.create()
        location = Location.objects.create()
        payment = Payment.objects.create()
        socialmarketing = SocialMarketing.objects.create()
        agenda = Agenda.objects.create()
        live = LiveStream.objects.create()
        user = User.objects.create()
        category = Category.objects.create()
        template = CreatorTemplate.objects.create(media = media, payment = payment, location = location, agenda = agenda, liveStream = live, socialMarketing = socialmarketing)
        event = Event.objects.create(template=template, creator = user, countShare = 1)
        currentComponent=SelectedComponents.objects.create(name="Location",template=template)
        session = self.client.session
        session['eventid'] = event.id
            
    def test_viewUnchosenComponents(self):

        resp = self.client.post('/CreatePage/')
        self.assertEqual(resp.status_code, 200)  
        self.assertEqual( "isLocation", "true")

    def test_addUnchosenComponents(self):    
        resp = self.client.post('/addUnchosenComponents/',{'name': "Add Live Stream"})
        self.assertEqual(resp.status_code, 302) 
        self.assertEqual(SelectedComponents.objects.get(pk=1).name, "Live Stream" )		

class searchEngineTestCase(TestCase):
	"""
	Author: Dalia Hosny 
	Story: C5-07
	"""		
	def test_searchEngine_homePage(self):
        resp = self.client.post('/homePage/', {'Categories':"Category", 'search':"Wedding"})
        self.assertEqual(resp.status_code, 302)
		
	def test_searchEngine_DashboardHome(self):
        resp = self.client.post('/login/', {'Categories':"Category", 'search':"Wedding"})
        self.assertEqual(resp.status_code, 302)		
		
        
class HomePageTestCase(TestCase):
    """
    Author: Amina Kadry
    Story: C1-1
    """
    def test_homePage(self):
        resp = self.client.get('/homePage/')
        self.assertEqual(resp.status_code, 200)
        
class SignupTestCase(TestCase):
    """
    Author: Amina Kadry
    Story: C1-1
    """
    def setUp(self):
        self.user = User.objects.create(first_name = "Amina", last_name= "Kadry", email = "amina.kadry@gmail.com", password = "abc123", confirmpassword = "abc123", phone="01118800088")
    def test_signup(self):
        self.assertEqual(self.user.email, "amina.kadry@gmail.com")
        
class ActivateAccountTestCase(TestCase):
    """
    Author: Amina Kadry
    Story: C1-1
    """
    def test_index(self):
        resp = self.client.get('/activateAccount/')
        self.assertEqual(resp.status_code,200)
        
class ActivateTestCase(TestCase):
    """
    Author: Amina Kadry
    Story: C1-1
    """
    def setUp(self):
        self.user = User.objects.create(first_name = "Amina", last_name= "Kadry", email = "amina.kadry@gmail.com", password = "abc123", confirmpassword = "abc123", phone="01118800088")
    def test_activate(self):
        resp = self.client.post('/activate/',{'activationEmail' :self.user.email, 'activationPassword':self.user.password, 'number': self.user.id})
        self.assertEqual(resp.status_code, 200)
        #self.assertEqual(self.user.Active,True)
        
class LogoutTestCase(TestCase):
    """
    Author: Amina Kadry
    Story: C1-13
    """
    def setUp(self):
        self.user = User.objects.create(first_name = "Amina", last_name= "Kadry", email = "amina.kadry@gmail.com", password = "abc123", confirmpassword = "abc123", phone="01118800088")
        session = self.client.session
        #self.session['email'] = User.objects.get(first_name="Amina").email
    def test_logout(self):
        resp = self.client.post('/logout/')
        self.assertEqual(resp.status_code,200)
        #self.assertEqual(self.session['email'], " ")

class SendInvitationTestCase(TestCase):
    """
    Author: Amina Kadry
    Story: C1-12
    """
    def setUp(self):
        media = Media.objects.create()
        location = Location.objects.create()
        payment = Payment.objects.create()
        socialmarketing = SocialMarketing.objects.create()
        agenda = Agenda.objects.create()
        live = LiveStream.objects.create()
        user = User.objects.create()
        category = Category.objects.create()
        template = CreatorTemplate.objects.create(media = media, payment = payment, location = location, agenda = agenda, liveStream = live, socialMarketing = socialmarketing)
        event = Event.objects.create(template=template, creator = user, countShare = 1)
        currentComponent=SelectedComponents.objects.create(name="Location",template=template)
        session = self.client.session
        session['eventid'] = event.id
        self.user = User.objects.create(first_name = "Amina", last_name= "Kadry", email = "amina.kadry@gmail.com", password = "abc123", confirmpassword = "abc123", phone="01118800088")
    def sendInvitation(self):
        resp = self.client.get('/sendInvitation/')
        self.assertEqual(resp.status_code,200)
        
class InviteTestCase(TestCase):
    """
    Author: Amina Kadry
    Story: C1-12
    """
    def setUp(self):
        user1 = User.objects.create(first_name = "Amina", last_name= "Kadry", email = "amina.kadry@gmail.com", password = "abc123", confirmpassword = "abc123", phone="01118800088")
        media = Media.objects.create()
        location = Location.objects.create()
        payment = Payment.objects.create()
        socialmarketing = SocialMarketing.objects.create()
        agenda = Agenda.objects.create()
        live = LiveStream.objects.create()
        user2 = User.objects.create(first_name="Menna", last_name="Khaled", email="menna.khaled92@gmail.com", password = "abc123", confirmpassword = "abc123", phone="01001431544")
        category = Category.objects.create()
        template = CreatorTemplate.objects.create(media = media, payment = payment, location = location, agenda = agenda, liveStream = live, socialMarketing = socialmarketing)
        event = Event.objects.create(template=template, creator = user1, countShare = 1)
        currentComponent=SelectedComponents.objects.create(name="Location",template=template)
        session = self.client.session
        session['eventid'] = event.id
        
        
    def invite(self):
        resp = self.client.post('/invite/', {'email': self.user2.email})
        self.assertEqual(resp.status_code,302)
        self.assertEqual(Invited.objects.get(id=1).email, "menna.khaled92@gmail.com")
class PageViewsTestCase(TestCase):
    """Author: Inas Khodeir"""
    def setUp(self):
        self.user = User.objects.create(first_name = "Inas",last_name="Khodeir",email = "inas.khodeir@gmail.com", password= "12345", confirmpassword ="12345", phone = "01110445575")
        self.media = Media.objects.create()
        self.location = Location.objects.create()
        self.payment = Payment.objects.create()
        self.socialmarketing = SocialMarketing.objects.create()
        self.agenda = Agenda.objects.create(title = "My Agenda")
        self.live = LiveStream.objects.create()
        self.user = User.objects.create()
        self.category = Category.objects.create()
        self.template = CreatorTemplate.objects.create(media = self.media, payment = self.payment, location = self.location, agenda = self.agenda, liveStream = self.live, socialMarketing = self.socialmarketing)
        self.event = Event.objects.create(template=self.template, creator = self.user, countShare = 1)
        self.Page = Pages.objects.create(category = self.category, event = self.event, title = "Inas", description = "Inas Ahmed Khodeir")
        self.Page.description = "Inas Ahmed"
		self.activity = Activity.objects.create(description = "Hiiii", startTime="5:00", endTime = "6:00", agendaID=self.agenda.id )
#    def testUser(self):
#        self.assertEqual(self.user.email,"inas.khodeir@gmail.com")
    """Author: Inas Khodeir"""
    def testPage(self):
        self.assertEqual(self.Page.title,"Inas")
        
    """Author: Inas Khodeir"""    
    def testEdit(self):
        resp = self.client.post('/CreatePage/')
        self.assertEqual(resp.status_code,200)
    
    """Author: Inas Khodeir"""   
    def testdelete(self):
        resp = self.client.post('/editCMS/')
        self.assertEqual(resp.status_code,302)
        self.assertEqual(self.Page.description, "Inas Ahmed")
    
    """Author: Inas Khodeir"""   
    def testEvent(self):
        resp = self.client.post('/EventsPage/')
        self.assertEqual(resp.status_code, 200)
		"""Author: Sarah Hesham"""
    def testAgenda(self):
        self.assertEqual(self.Page.title,"My Agenda")
		
    """Author: Sarah Hesham"""
    def testAddActivity(self):
        resp = self.client.post('/createActivity/')
        self.assertEqual(resp.status_code,200)
        self.assertEqual(self.activity.agendaID, self.agenda.id)
    """Author: Sarah Hesham"""
    def testDeleteActivity(self):
        resp = self.client.post('/deleteActivity/')
        self.assertEqual(resp.status_code,200)



class assignTaskTest(TestCase):
	""" Author : Reem Tarek"""
	def setUp(self):
		media = Media.objects.create()
	        location = Location.objects.create()
	        payment = Payment.objects.create()
	        socialmarketing = SocialMarketing.objects.create()
	        agenda = Agenda.objects.create()
	        live = LiveStream.objects.create()
	        user = User.objects.create(email = "hana.s.elsherif@gmail.com")
	        moderator = User.objects.create(email = "amina.kadry@gmail.com")

	        category = Category.objects.create()
	        template = CreatorTemplate.objects.create(media = media, payment = payment, location = location, agenda = agenda, liveStream = live, socialMarketing = socialmarketing)
	        event = Event.objects.create(template=template, creator = user ,countShare = 1)
	        session = self.client.session
	        session ['eventid'] = event.id
	        list = List.objects.create( event = event)
	        item = Item.objects.create( todoList = list , title = "test")

	        session ['list'] = list
	        eventModerator = EventModerator.objects.create(event = event , user = moderator)
	def test_index(self):

	        resp= self.client.post('/assignTask/' , {'Moderators': self.eventModerator.user.email ,'task' : self.item.id })
	        self.assertEqual(resp.status_code , 302)


class ProgressListTest(TestCase):
    """ Author : Reem Tarek"""

    def setUp(self):
        
        media = Media.objects.create()
        location = Location.objects.create()
        payment = Payment.objects.create()
        socialmarketing = SocialMarketing.objects.create()
        agenda = Agenda.objects.create()
        live = LiveStream.objects.create()
        user = User.objects.create(email = "hana.s.elsherif@gmail.com")
        moderator = User.objects.create(email = "amina.kadry@gmail.com")
        
        category = Category.objects.create()
        template = CreatorTemplate.objects.create(media = media, payment = payment, location = location, agenda = agenda, liveStream = live, socialMarketing = socialmarketing)
        event = Event.objects.create(template=template, creator = user ,countShare = 1)
        list = List.objects.create( event = event)
        item = Item.objects.create( todoList = list , title = "test" ,completed = True)
        item2 = Item.objects.create( todoList = list , title = "test2" ,completed = True)
    
    
    def test_index(self):
        resp= self.client.post('/EventPage/1/$/')
        self.assertEqual( resp , 100)
class ListTestCase(TestCase):
    """Author: Menna Khaled"""
    def setUp(self):
        user = User.objects.create(first_name = "Menna",last_name="Khaled",email = "menna.khaled92@gmail.com", password= "12345", confirmpassword ="12345", phone = "01001431544")
        self.location = Location.objects.create()
        self.payment = Payment.objects.create()
        self.socialmarketing = SocialMarketing.objects.create()
        self.agenda = Agenda.objects.create()
        self.live = LiveStream.objects.create()
        self.user = User.objects.create()
        self.category = Category.objects.create()
        self.template = CreatorTemplate.objects.create( payment = self.payment, location = self.location, agenda = self.agenda, liveStream = self.live, socialMarketing = self.socialmarketing)
        event = Event.objects.create(template=self.template, creator = self.user, countShare = 1)
        session = self.client.session
        session['eventid'] = event.id
        self.list = List.objects.create(title = "menna", event = self.event)
        self.item = Item.objects.create(title = "listtt", todoList = self.list)
        self.item.assignedTo = "Menna"+ "" + "Khaled"
    """Author: Menna Khaled"""
    def testItem(self):
        self.assertEqual(self.item.title,"listtt")
    """Author: Menna Khaled"""
    def testAddTask(self):
        resp = self.client.post('/AddTask/')
        self.assertEqual(resp.status_code, 200)
    """Author: Menna Khaled"""
    def testAssignedTask(self):
        self.assertEqual(self.list.title, "menna", self.item.title,"listtt", self.item.todoList,self.list, self.item.assignedTo, "Menna"+""+"Khaled")
        resp = self.client.post('/EventPage/1/$')
        self.assertEqual(resp.status_code, 200)

"""Author: Dalia Hegazy"""       
class PopularityTest(TestCase):
    def setUp(self):        
        creator = User(1,'Dalia','Hegazy','dalia.m.hegazy@gmail.com','12345','12345','1234567890','1','0')
        creator.save()
        user = User(2,'testttt','tessssttttt','lilcuteangel_91@hotmail.com','12345','12345','1234567890','1','0')
        user.save()
        payment = Payment(1,'50 LE','2012-05-29')
        payment.save()
        media = Media(1,'')
        media.save()        
        location = Location(1,'nasr city')
        location.save()        
        agenda = Agenda(1,'birthday')
        agenda.save()        
        liveStream = LiveStream(1,'not chosen')
        liveStream.save()        
        socialMarket = SocialMarketing(1,'dalia','facebook.com/test/','dalia')
        socialMarket.save()        
        template = CreatorTemplate(1,'birthday','2012-01-1','2012-01-1','11:00','11:30','birthday',1,1,1,1,1,1,'me','me')
        template.save()        
        event = Event(1,1,'1','1','0',1,'1','0','2012-01-1') 
        event.save()
        self.myCreator = creator 
        self.myUser = user
        self.myEvent = event
        
        from django.contrib.auth import models
        models.User.objects.create_superuser('admin', 'admin@admin.com', 'admin')
        self.client.login(username='admin', password='admin')
    
    """Author: Dalia Hegazy"""
    def test_measureAttendee(self):
        session = self.client.session
        session['email'] = self.myCreator.email
        session.save()

        resp = self.client.get('/chartAttendee/1/')
        self.assertEqual(resp.status_code, 200)
        self.assertEqual(resp.context['attendingUser'], 0)
        self.assertEqual(resp.context['maybeAttendingUser'], 0)
        self.assertEqual(resp.context['notAttendingUser'], 0)
        self.assertEqual(resp.context['errorMsg'], 'not')
        
        Attending(1,self.myUser.id,self.myEvent.id).save()
        MaybeAttending(1,self.myUser.id,self.myEvent.id).save()
        NotAttending(1,self.myUser.id,self.myEvent.id).save()
        
        resp = self.client.get('/chartAttendee/1/')
        self.assertEqual(resp.status_code, 200)
        self.assertEqual(resp.context['attendingUser'], 1)
        self.assertEqual(resp.context['maybeAttendingUser'], 1)
        self.assertEqual(resp.context['notAttendingUser'], 1)
        self.assertEqual(resp.context['errorMsg'], '')
    
    """Author: Dalia Hegazy"""    
    def test_measureLike(self):
        session = self.client.session
        session['email'] = self.myCreator.email
        session.save()

        resp = self.client.get('/chartLike/1/')
        self.assertEqual(resp.status_code, 200)
        self.assertEqual(resp.context['likeEventCount'], 0)
        self.assertEqual(resp.context['errorMsg'], 'not')
        
        LikeEvent(1,self.myUser.id,self.myEvent.id).save()
        
        resp = self.client.get('/chartLike/1/')
        self.assertEqual(resp.status_code, 200)
        self.assertEqual(resp.context['likeEventCount'], 1)
        self.assertEqual(resp.context['numberOfLikes1'], 1)
        self.assertEqual(resp.context['numberOfLikes2'], 1)
        self.assertEqual(resp.context['numberOfLikes3'], 1)
        self.assertEqual(resp.context['numberOfLikes4'], 1)
        
        """Author: Dalia Hegazy"""
class ShareLikeTest(TestCase):
    def setUp(self):        
        user1 = User(1,'Dalia','Hegazy','dalia.m.hegazy@gmail.com','12345','12345','1234567890','1','0')
        user1.save()
        payment = Payment(1,'90 LE','2012-02-20')
        payment.save()
        media = Media(1,'')
        media.save()
        location = Location(1,'nasr city')
        location.save()
        agenda = Agenda(1,'xxxxx')
        agenda.save()
        liveStream = LiveStream(1,'not chosen')
        liveStream.save()
        socialMarket = SocialMarketing(1,'dalia','facebook.com/test/','dalia')
        socialMarket.save()
        template = CreatorTemplate(1,'xxxxxx','2012-09-12','2012-09-12','11:00','12:00','xxxxxx',1,1,1,1,1,1,'dd','dd')
        template.save()
        event = Event(1,1,'1','1','0',1,'1','0','2012-09-12') 
        event.save()
        self.myUser1 = user1
        self.myEvent = event
        
        from django.contrib.auth import models
        models.User.objects.create_superuser('admin', 'admin@admin.com', 'admin')
        self.client.login(username='admin', password='admin')
    
    """Author: Dalia Hegazy"""
    def test_shareEvent(self):
        session = self.client.session
        session['email'] = self.myUser1.email
        session.save()

        resp = self.client.post('/EventPage/1/share/')
        self.assertEqual(resp.status_code, 302)
        self.assertEqual(resp['Location'], 'http://testserver/EventPage/1')
        self.assertEqual(Event.objects.get(pk=1).countShare, 1)
    
    """Author: Dalia Hegazy"""    
    def test_measureLike(self):
        session = self.client.session
        session['email'] = self.myUser1.email
        session.save()

        resp = self.client.post('/EventPage/1/like/1/')
        self.assertEqual(resp.status_code, 302)
        likeCount = LikeEvent.objects.filter(event=self.myEvent).count()
        self.assertEqual(likeCount, 1)
        
        resp = self.client.post('/EventPage/1/like/1/')
        self.assertEqual(resp.status_code, 302)
        likeCount = LikeEvent.objects.filter(event=self.myEvent).count()
        self.assertEqual(likeCount, 0)
	    """Author: Ola Magdy"""
    def settingUp(self):
        self.location = Location.objects.create( BlockNumber="1",Street="Abbas El Akkad",city="Cairo",Country="Egypt")
        self.payment = Payment.objects.create(paymentAmount="20")
        self.socialmarketing = SocialMarketing.objects.create(hashTag="#Eventi")
        self.liveStream = LiveStream.objects.create(channel="http://www.ustream.tv/recorded/22738033/highlight/265586#utm_campaign=fhighlights&utm_source=2&utm_medium=pets-animals")
        self.agenda = Agenda.objects.create()
        self.live = LiveStream.objects.create()
        self.user = User.objects.create()
        self.category = Category.objects.create()
        self.template = CreatorTemplate.objects.create(media = self.media, payment = self.payment, location = self.location, agenda = self.agenda, liveStream = self.live, socialMarketing = self.socialmarketing)
        self.event = Event.objects.create(template=self.template, creator = self.user, countShare = 1)
        self.socialmarketing.hashTag="#Eventati"
        self.liveStream.channel="http://www.ustream.tv/recorded/22625258/highlight/263913#utm_campaign=fhighlights&utm_source=5&utm_medium=pets-animals"
        
    """Author: Ola Magdy"""       
    def test_viewEditLocation(self):
        response = self.client.post('/viewEditLocation/')
        self.assertEqual(response.status_code,200)
    """Author: Ola Magdy"""    
    def test_editLocation(self):
        response = self.client.post('/EditLocation/',{'Street':"Al Nasr"})
        self.assertEqual(response.status_code,200)
        self.assertEqual(self.location.Street,"Al Nasr")
    """Author: Ola Magdy"""   
    def test_viewEditPayment(self):
        response = self.client.post('/viewEditPayment/')
        self.assertEqual(response.status_code,200)
    """Author: Ola Magdy"""    
    def test_editPayment(self):
        response = self.client.post('/EditPayment/',{'paymentAmount':"40"})
        self.assertEqual(response.status_code,200)
        self.assertEqual(self.payment.paymentAmount,"40")
    """Author: Ola Magdy"""    
    def test_viewEditAgenda(self):
        response = self.client.post('/viewEditAgenda/')
        self.assertEqual(response.status_code,200)
    """Author: Ola Magdy"""    
    def test_viewEditSocialMarketing(self):
        response = self.client.post('/viewEditSocialMarketing/')
        self.assertEqual(response.status_code,200)
    """Author: Ola Magdy""" 
    def test_editSocialMarketing(self):
        response = self.client.post('/EditSocialMarketing/',{'hashTag':"#Eventati"})
        self.assertEqual(response.status_code,200)
        self.assertEqual(self.socialmarketing.hashTag, "#Eventati")
    """Author: Ola Magdy"""    
    def test_viewEditLiveStream(self):
        response = self.client.post('/viewEditLiveStream/')
        self.assertEqual(response.status_code,200)  
    """Author: Ola Magdy"""   
    def test_editLiveStream(self):
        response = self.client.post('/EditLiveStream/',{'channel':"http://www.ustream.tv/recorded/22625258/highlight/263913#utm_campaign=fhighlights&utm_source=5&utm_medium=pets-animals"})
        self.assertEqual(response.status_code,200)
        self.assertEqual(self.liveStream.channel,"http://www.ustream.tv/recorded/22625258/highlight/263913#utm_campaign=fhighlights&utm_source=5&utm_medium=pets-animals")
     
"""Author:Heba El Mohandes"""   
class Compontent(TestCase):
    def setUp(self):
        user = User(1,'Heba','Mohamed','heba.m.elmohandes@gmail.com','12345','12345','1234567890','1','0')
        user.save()
        self.user = user
        
        #adding superuser to db to able to use session
        from django.contrib.auth import models
        models.User.objects.create_superuser('admin', 'admin@admin.com', 'admin')  
        self.client.login(username='admin', password='admin')
        
    def test_suggestComponent(self):        
        resp = self.client.get('/SuggestComponent/')
        self.assertEqual(resp.status_code, 302)
        self.assertEqual(resp['Location'], 'http://testserver/homePage/')
        
        session = self.client.session
        session['email'] = self.user.email
        session.save()
        
        resp = self.client.get('/SuggestComponent/')
        self.assertEqual(resp.status_code, 200)
        
        name = 'heba'
        desc = 'anything'
        resp = self.client.post('/SuggestComponent/',{'name':name,'desc':desc})
        self.assertEqual(resp.status_code, 302)
        self.assertEqual(resp['Location'], 'http://testserver/homePage/')
        
        component = Component.objects.get(id=1)
        self.assertEqual(component.title,name)
        self.assertEqual(component.description,desc)
        
    def test_viewComponent(self):        
        name = "heba"
        desc = "anything"
        component = Component(title=name,description=desc,approved=0,rejected=0)
        component.save()
        resp = self.client.get('/ViewComponent/1/')
        self.assertEqual(resp.status_code, 200)
        self.assertEqual(resp.context['component'].title,name)
        self.assertEqual(resp.context['component'].description,desc)
        
    def test_viewComp(self):
        name = "heba"
        desc = "anything"
        component = Component(title=name,description=desc,approved=0,rejected=0)
        component.save()
        self.assertEqual(component.viewComp(),'<a href="../../../ViewComponent/1/">View</a>')
        
  """Author:Heba El Mohandes""" 
class test_editEvent(TestCase):
    def setUp(self):
        #adding superuser to db to able to use session
        from django.contrib.auth import models
        models.User.objects.create_superuser('admin', 'admin@admin.com', 'admin')
        self.client.login(username='admin', password='admin')
        
        moderator = User(1,'Heba','Elmohandes','heba.m.elmohandes@gmail.com','12345','12345','1234567890','1','0')
        moderator.save()
        
        payment = Payment(1,'50 LE','2012-05-29')
        payment.save()
        
        media = Media(1,'')
        media.save()
        
        location = Location(1,'Tagamo3')
        location.save()
        
        agenda = Agenda(1,'Wedding Planner')
        agenda.save()
        
        liveStream = LiveStream(1,'not chosen')
        liveStream.save()
        
        socialMarket = SocialMarketing(1,'Eman','facebook.com/test/','Eman')
        socialMarket.save()
        
        template = CreatorTemplate(1,'Wedding','2012-05-28','2012-05-30','10:00','12:00','Wedding',1,1,1,1,1,1,'He','Ba')
        template.save()
        
        event = Event(1,1,'1','1','0',1,'1','0','2012-05-30') 
        event.save()
        
        eventModerator = EventModerator(1,1,1)
        eventModerator.save()
        
        self.moderator = moderator
        self.event = event
        self.template = template
        
    def test_editEvent(self):
        session = self.client.session
        session['email'] = self.moderator.email
        session.save()

        resp = self.client.get('/eventEdit/1/')
        self.assertEqual(resp.status_code, 200)
        self.assertEqual(resp.context['event'], self.event)
        self.assertEqual(resp.context['template'], self.template)
        self.assertEqual(resp.context['startDate'], self.template.startDate)
        self.assertEqual(resp.context['endDate'], self.template.endDate)
        self.assertEqual(resp.context['startTimeHour'], int(self.template.startTime.split(':')[0]))
        self.assertEqual(resp.context['startTimeMinute'], int(self.template.startTime.split(':')[1]))
        self.assertEqual(resp.context['endTimeHour'], int(self.template.endTime.split(':')[0]))
        self.assertEqual(resp.context['endTimeMinute'], int(self.template.endTime.split(':')[1]))
        
        name='any'
        startDate = '2012-06-07'
        endDate = '2012-06-10'
        startTimeHour = 20
        startTimeMinute = 0
        endTimeHour = 22
        endTimeMinute = 0
        private = 'on'
        
        import datetime 

        resp = self.client.post('/eventEdit/1/',{'name':name,'startDate':startDate,'endDate':endDate,'startTimeHour':startTimeHour,'startTimeMinute':startTimeMinute,'endTimeHour':endTimeHour,'endTimeMinute':endTimeMinute,'private':private})
        self.assertEqual(resp.status_code, 302)
        newTemplateData = CreatorTemplate.objects.get(pk=1)
        newEventData = Event.objects.get(pk=1)
        self.assertEqual(newTemplateData.name, name)
        self.assertEqual(newTemplateData.eventName, name)
        self.assertEqual(newTemplateData.startDate, datetime.date(2012,6,7))
        self.assertEqual(newTemplateData.endDate, datetime.date(2012,6,10))
        self.assertEqual(newTemplateData.startTime, datetime.time(20,0))
        self.assertEqual(newTemplateData.endTime, datetime.time(22,0))
        self.assertEqual(newEventData.isPublic, 0)
		
		
class SocialMarketingTest(TestCase):
	""" Author: Nermeen Hashem """
    def setUp(self):
        from django.contrib.auth import models
        models.User.objects.create_superuser('admin', 'admin@admin.com', 'admin')
        self.client.login(username='admin', password='admin')
        
        user = User(1,'Nermeen','Hashem','nermeen.hashem@gmail.com','1234','1234','123456789','1','0')
        user.save()
        payment = Payment(1,'10 LE','2012-02-20')
        payment.save()
        media = Media(1,'')
        media.save()
        location = Location(1,'madii')
        location.save()
        agenda = Agenda(1,'tessttt')
        agenda.save()
        liveStream = LiveStream(1,'not chosen')
        liveStream.save()
        socialMarket = SocialMarketing(1,'nermeen','facebook.com/test/','hashem')
        socialMarket.save()
        template = CreatorTemplate(1,'test','2012-12-13','2012-12-13','01:00','02:00','testt',1,1,1,1,1,1,'nedsfgsd','sdsdf')
        template.save()
        event = Event(1,1,'1','1','0',1,'1','0','2012-12-13') 
        event.save()
        
        session = self.client.session
        session['email'] = user.email
        session['eventid'] = event.id
        session.save()
        



    def test_setSocialMarketing(self):
        response = self.client.post('/social/',{'facebookUrl':'https://www.facebook.com/DrHouse','twitterUserName':'nermeen','hashTag':'Faith'})
        self.assertEqual(response.status_code,200)
        socialMarketing = SocialMarketing.objects.filter(pk=2)
        self.assertEqual(socialMarketing.count(), 1)

class BooKmarksTest(TestCase):
    """Author: Fouad Hesham"""
    def setUp(self):
        self.user = User.objects.create(first_name = "Fouad",last_name="Hesham",email = "fouad.hesham@gmail.com", password= "12345", confirmpassword 		="12345", phone = "01110445575")
        self.media = Media.objects.create()
        self.location = Location.objects.create()
        self.payment = Payment.objects.create()
        self.socialmarketing = SocialMarketing.objects.create()
        self.agenda = Agenda.objects.create(title = "My Agenda")
        self.live = LiveStream.objects.create()
        self.user = User.objects.create()
        self.category = Category.objects.create()
        self.template = CreatorTemplate.objects.create(media = self.media, payment = self.payment, location = self.location, agenda = self.agenda, 		liveStream = self.live, socialMarketing = self.socialmarketing)
        self.event = Event.objects.create(template=self.template, creator = self.user, countShare = 1)
        self.bookmark= Bookmark.objects.create(user=self.user,event=self.event)
    """Author: Fouad Hesham"""
    def testPage(self):
        self.assertEqual(self.Page.title,"Fouad")
        
    """Author: Fouad Hesham"""
    def testDeleteEvent(self):
        resp = self.client.post('/deleteEvent/')
        self.assertEqual(resp.status_code,200)
    """Author: Fouad Hesham"""
    def testAddBookmark(self):
        self.assertEqual(self.bookmark.event, self.event)
    """Author: Fouad Hesham"""
    def testDeleteBookmark(self):
        resp = self.client.post('/deleteBookmark/')
        self.assertEqual(resp.status_code,200
		
		
 """Author: Hadeel Mohamed"""
class InformationTest(TestCase):
    def setUp(self):
        self.CreatorTemplate.startTime = CreatorTemplate.objects.create("00:00")
        self.CreatorTemplate.EndTime = CreatorTemplate.objects.create("00:01")
        self.CreatorTemplate.startDate = CreatorTemplate.objects.create("2012-05-30")
        self.CreatorTemplate.endDate = CreatorTemplate.objects.create("2012-05-31")
        self.CreatorTemplate.eventName = CreatorTemplate.objects.create("MY EVENT")
        self.CreatorTemplate.brideName = CreatorTemplate.objects.create("mai")
        self.CreatorTemplate.groomName = CreatorTemplate.objects.create("mohamed")
        self.CreatorTemplate.birthdayOwner = CreatorTemplate.objects.create("ahmed")
        self.CreatorTemplate.singerName = CreatorTemplate.objects.create("ali")
        self.CreatorTemplate.charityType = CreatorTemplate.objects.create("for the poor")
        self.CreatorTemplate.description =CreatorTemplate.objects.create("thats my event")
    
        
       """Author: Hadeel Mohamed"""
	def test_viewEditBasicInformation(self):
		
			response = self.client.post('/viewEditBasicInformation/')
			self.assertEqual(response.status_code,200)
			
	   """Author: Hadeel Mohamed"""
	def test_editBasicInformation(self):
		
			response = self.client.post('/EditBasicInformation/')
			self.assertEqual(self.eventName.name,"Hadeel's event")
			self.assertEqual(self.startDate.date,"2012-06-01")
			self.assertEqual(self.endDate.date,"2012-6-05")
			self.assertEqual(self.statTime.time,"9:00")
			self.assertEqual(self.endTime.time,"9:30")
			self.assertEqual(response.status_code,200)
